
with Ada.Text_IO; 		use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Command_Line; 	use Ada.Command_Line;

procedure ref_conditionals is 
	function celsius_from(farenheit: in float) return float is
		celsius : float := (farenheit - 32.0)/1.80;
	begin
		return celsius;
	end celsius_from;

	function farenheit_from(celsius: in float) return float is
		farenheit : float := (celsius * 1.80) + 32.0;
	begin
		return farenheit;
	end farenheit_from;

	--type degrees is new Float range -459.67 .. Float'Last;
	input : string := argument(1);
	temperature : float := float'value(input);
	f : float;
	c : float;
begin
	put_line("°F  to °C converter (and conditionals demo)");
	put("degrees entered: ");
	--fore=>3, aft=>2, exp=>0
	put(temperature, 3, 2, 0);
	new_line;
	f := farenheit_from(temperature);
	put("farenheit <- celsius: ");
	put(f,3,2,0);
	new_line;
	c := celsius_from(temperature);
	put("celsius <- farenheit: ");
	put(c,3,2,0);
	new_line;
	if c < -273.15 or f < -459.67 then
		put_line("one measurement is below absolute zero.");
	elsif c <= 0.0 and f <= 32.0 then
		put_line("water freezes regardless of unit.");
	end if;
end ref_conditionals;
